/**
 * Created by Administrator on 2017/3/21.
 */
import axios from './http.js';
import qs from 'qs'
import Path from './path'
import {
  resfulParamsToUrl
} from './resfulUrl'
//用户
export const login = params => {
  return axios.post(resfulParamsToUrl(Path.login, params), qs.stringify(params))
}
export const register = params => {
  return axios.post(resfulParamsToUrl(Path.register, params), params)
}
export const getLoginUserInfo = params => {
  return axios.get(resfulParamsToUrl(Path.getLoginUserInfo, params), {
    params
  })
}
export const checkUserExist = params => {
  return axios.get(resfulParamsToUrl(Path.checkUserExist, params), {
    params
  })
}
//加油记录
export const getRefuelLogAll = params => {
  return axios.get(resfulParamsToUrl(Path.getRefuelLogAll, params), {
    params
  })
}
export const getPerMonth = params => {
  return axios.get(resfulParamsToUrl(Path.getPerMonth, params), {
    params
  })
}
export const getRefuelLogInStation = params => {
  return axios.get(resfulParamsToUrl(Path.getRefuelLogInStation, params), {
    params
  })
}
export const getOilPrice = params => {
  return axios.get(resfulParamsToUrl(Path.getOilPrice, params), {
    params
  })
}
export const getAntiWeightToken = params => {
  return axios.get(resfulParamsToUrl(Path.getAntiWeightToken, params), {
    params
  })
}
export const delRefuelLogById = params => {
  return axios.delete(resfulParamsToUrl(Path.delRefuelLogById, params), {
    params
  })
}
export const newRefuelLog = (params, token) => {
  return axios.post(resfulParamsToUrl(`${Path.newRefuelLog}${token ? "?antiWeightToken=" + token : ""}`, params), params)
}
export const updateRefuelLogById = params => {
  return axios.post(resfulParamsToUrl(Path.updateRefuelLogById, params), params)
}
export function downLoadExcel(params) {
  return axios({
    url: Path.downLoadExcel,
    method: "get",
    timeout: 100000,
    responseType: "blob",
    params
  });
}
//加油站
export const getStationAll = params => {
  return axios.get(resfulParamsToUrl(Path.getStationAll, params), {
    params
  })
}
export const getAvgOil = params => {
  return axios.get(resfulParamsToUrl(Path.getAvgOil, params), {
    params
  })
}
//看板
export const getKanbanInfo = params => {
  return axios.get(resfulParamsToUrl(Path.getKanbanInfo, params), {
    params
  })
}
export const createBoard = params => {
  return axios.post(resfulParamsToUrl(Path.createBoard, params), params)
}
export const delBoard = params => {
  return axios.delete(resfulParamsToUrl(Path.delBoard, params), {
    params
  })
}
export const moveBoard = params => {
  return axios.post(resfulParamsToUrl(Path.moveBoard, params), params)
}
export const createTask = params => {
  return axios.post(resfulParamsToUrl(Path.createTask, params), params)
}
export const delTask = params => {
  return axios.delete(resfulParamsToUrl(Path.delTask, params), {
    params
  })
}
export const moveTask = params => {
  return axios.post(resfulParamsToUrl(Path.moveTask, params), params)
}

//getlab
export const getGitProjects = params => {
  return axios.get(resfulParamsToUrl(Path.getGitProjects, params), {
    params
  })
}
export const getGitDiff = params => {
  return axios.get(resfulParamsToUrl(Path.getGitDiff, params), {
    params
  })
}
export const getBranchDiff = params => {
  return axios.get(resfulParamsToUrl(Path.getBranchDiff, params), {
    params
  })
}
export const getCommits = params => {
  return axios.get(resfulParamsToUrl(Path.getCommits, params), {
    params
  })
}
export const getBranches = params => {
  return axios.get(resfulParamsToUrl(Path.getBranches, params), {
    params
  })
}

//动态路由
export const getRounts = params => {
  return axios.get(resfulParamsToUrl(Path.getRounts, params), {
    params
  })
}

//ajax重定向
export const redirectAjax = axios.defaults.baseURL + Path.redirectAjax;
